﻿using Microsoft.Practices.Unity;
using UnityDemo.LoggingUtility;
using UnityDemo.Models;

namespace UnityDemo.RegAndResCode
{
    internal class RegistrationCheck : ISample
    {
        public RegistrationCheck()
        {
            var container = new UnityContainer(); // UnityInstanceProvider.NewUnityInstance;

            //Registering IDuck and its implementing class
            container.RegisterType<IDuck, KingDuck>();
            container.RegisterType<IDuck, QueenDuck>();

            if (!container.IsRegistered<IDuck>())
            {
                LogerInstance.Logger.Warn("Interface is not registered");
                container.RegisterType<IDuck, KingDuck>();
            }

            if (!container.IsRegistered<IQuackStrategy>())
            {
                LogerInstance.Logger.Warn("IQuackStrategy is not registered");
            }

            if (!container.IsRegistered<KingDuck>())
            {
                LogerInstance.Logger.Warn("KingDuck is not registered");
                container.RegisterType<IDuck, KingDuck>();
            }

            if (!container.IsRegistered<SoldierDuck>())
            {
                LogerInstance.Logger.Warn("Soldier duck is not registered");
                container.RegisterType<IDuck, SoldierDuck>();
            }
        }
    }
}